import 'package:flutter/cupertino.dart';
import 'package:regular_assess/helper/utils/localization/localization.dart';
import 'package:regular_assess/helper/utils/util.dart';

class LocalizationStrings {
  //英语
  static late Map<String, String> ens;

  ///藏语
  static late Map<String, String> bos;

  ///繁体
  static late Map<String, String> hks;

  // static LocalizationType type = LocalizationType.en;

  static String locaKey = 'localizationKey';

  static Locale get locale {
    switch (type) {
      case LocalizationType.en:
        return const Locale('en');
      case LocalizationType.bo:
        return const Locale('bo');
      case LocalizationType.hk:
        return const Locale('hk');
      default:
        return const Locale('zh');
    }
  }

  static List<LocalizationType> types = [
    LocalizationType.zh,
    LocalizationType.en,
    LocalizationType.bo,
    LocalizationType.hk,
  ];

  static String typeForKey(LocalizationType type) {
    switch (type) {
      case LocalizationType.en:
        return '英语';
      case LocalizationType.bo:
        return '藏语';
      case LocalizationType.hk:
        return '繁体';
      default:
        return '中文';
    }
  }

  static LocalizationType keyForType(String? key) {
    switch (key) {
      case '英语':
        return LocalizationType.en;
      case '藏语':
        return LocalizationType.bo;
      case '繁体':
        return LocalizationType.hk;
      default:
        return LocalizationType.zh;
    }
  }

  static var typeObs = LocalizationType.en.obs;

  static LocalizationType get type {
    return typeObs.value;
  }

  static set type(LocalizationType val) {
    typeObs.value = val;
    Get.updateLocale(locale);
    SpUtil().setStr(locaKey, typeForKey(val));
  }

  static register() {
    String? ls = SpUtil().getStr(locaKey);
    type = keyForType(ls);
    ens = {
      '登录': 'Login',
      '我的': 'Mine',
      '首页': 'Home',
    };

    bos = {
      '登录': 'ཐོ་འགོད།',
      '我的': 'ངའི།',
      '首页': 'ཤོག་ངོས།',
    };

    hks = {
      '登录': '登入',
      '我的': '我的',
      '首页': '首頁',
    };
  }
}
